package com.mindao.app.ued.controller;

import java.io.IOException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.google.zxing.WriterException;
import com.mindao.app.common.spring.controller.BaseController;
import com.mindao.app.common.spring.model.BaseModel;
import com.mindao.app.common.spring.page.Pagination;
import com.mindao.app.common.spring.service.util.JsonResult;
import com.mindao.app.ea.service.UserService;
import com.mindao.app.ued.model.Event;
import com.mindao.app.ued.service.EventPrizeService;
import com.mindao.utils.config.EaCommonUtils;
import com.mindao.utils.config.EaConstant;

/**
/* 版权所有： 广州敏道科技有限公司
/*
/* 功能描述：
/*
/* 创 建 人：李国才
/* 创建时间：2016年6月16日 下午1:03:24 	
 **/
@Controller
@RequestMapping("/ued/event")
public class EventController extends BaseController<Event> {
	@Autowired
	protected EventPrizeService eventPrizeService;
	
 
	
	 
	
	private final Logger log = LoggerFactory.getLogger(EventController.class);
	private static final DateFormat SIMPLE_DATE_FORMATER = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
 
	
	/** 初始化文本日期数据进行绑定 */
	@InitBinder
	public void initBinder(WebDataBinder binder) {
		binder.registerCustomEditor(Date.class, "deadline", new CustomDateEditor(SIMPLE_DATE_FORMATER, Boolean.TRUE));
		binder.registerCustomEditor(Date.class, "createTime", new CustomDateEditor(SIMPLE_DATE_FORMATER, Boolean.TRUE));
	}
	
	/**
	 * 加载分页列表数据
	 * @param request
	 * @param response
	 * @param session
	 * @param rhs
	 * @return
	 * @throws Exception
	 */
	@RequestMapping 
	public String search(HttpServletRequest request,HttpServletResponse response,HttpSession session,Model rhs) throws Exception {
		String view=super.searchPageAjax(request, response, session, rhs);
		Integer prizeNumber=eventPrizeService.getPrizeNumber();
		rhs.addAttribute("prizeNumber", prizeNumber);
		return view;
	}

}
